package com.seanzx.resolver.impl;

import com.seanzx.common.Result;
import com.seanzx.constant.SymbolTable;
import com.seanzx.lexical.Token;
import com.seanzx.resolver.IResolver;
import com.seanzx.dp.ProcessorController;

import java.util.List;

public class GetVariableResolver implements IResolver<String> {
    ProcessorController processorController = ProcessorController.get();

    @Override
    public boolean matches(List<Token> tokens) {
        return tokens.size() == 2 && SymbolTable.GET.equals(tokens.get(0).getValue());
    }

    @Override
    public String translate(List<Token> tokens) {
        return tokens.get(1).getValue();
    }

    @Override
    public boolean validate(Object parameter) {
        return true;
    }

    @Override
    public Result access(Object parameter) {
        return processorController.getProperties((String) parameter);
    }
}
